package com.zongxingh.falcon.logger.reader;

import com.zongxingh.falcon.logger.constant.LoggerGroup;
import com.zongxingh.falcon.logger.constant.LoggerLevel;
import com.zongxingh.falcon.logger.constant.LoggerTopic;
import com.zongxingh.falcon.mq.consumer.MQConsumerFactory;
import com.zongxingh.falcon.mq.consumer.MqConsumer;

/**
 * Introduction:  <简介>
 * Package Name:  com.zongxingh.falcon.logger.reader
 * Project Name:  falcon-logger
 * Author:  zongxingh
 * Email： zongxingh@163.com
 * Tel: 157*****778
 * Create Time:  2020/10/29 11:29
 */
public class LogReaderRegister {

    public static void register(AbstractLogReader logReader, LoggerLevel level){

        String registerTopic = switchRegisterTopic(level);
        MqConsumer mqConsumer = MQConsumerFactory.createMqConsumer(
                LoggerGroup.LOG_MSG_GROUP,
                registerTopic,
                logReader.getMqProperties(),
                logReader);
    }

    private static String switchRegisterTopic(LoggerLevel level){
        switch (level){
            case TRACE: return LoggerTopic.LOG_MSG_TOPIC_TRACE;
            case DEBUG: return LoggerTopic.LOG_MSG_TOPIC_DEBUG;
            case INFO: return LoggerTopic.LOG_MSG_TOPIC_INFO;
            case WARN: return LoggerTopic.LOG_MSG_TOPIC_WARN;
            case ERROR: return LoggerTopic.LOG_MSG_TOPIC_ERROR;
            default: return "";
        }
    }
}
